package com.chapter08;

import com.bdqn.util.JDBCUtils;
import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;

public class Test02_c3p0 {
    public static void main(String[] args) throws PropertyVetoException, SQLException {
        // todo 1、创建了一个数据源：包含 连接池 和 连接池管理
        ComboPooledDataSource cpds = new ComboPooledDataSource("intergalactoApp");
        cpds.setDriverClass( "com.mysql.jdbc.Driver" ); //loads the jdbc driver
        cpds.setJdbcUrl( "jdbc:mysql://127.0.0.1:3306/myschool?rewriteBatchedStatements=true" );
        cpds.setUser("root");
        cpds.setPassword("root");


        Connection connection = cpds.getConnection();
        // System.out.println(connection.getClass().getName());

        JDBCUtils.updateTx(connection,"INSERT INTO grade(`GradeId`,`GradeName`) VALUES(?,?);","201","你好");
        connection.close();
    }
}
